home *** CD-ROM | disk | FTP | other *** search
- /*
- Prototypes for MathPad's callback routines.
-
- This header file is for XFuns that do not use ANY A4 globals.
- In this case you can get by without doing SetUpA4 etc.
- The file "callback.c" implements these routines. The callback
- pointer must be passed to each routine.
-
- The compiler must be set so that type "double" is a SANE 80-bit.
-
- */
-
- typedef short (*funptr) (...);
- typedef struct expr *EXPR; /* internal details aren't needed by XFun */
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- /* ---------- control routines ---------------------------- */
-
- extern void AddXfun(char *name,char *parms,funptr entry,funptr predef,funptr callback);
- /* Install a new function from a code resource. */
- //(internally defined a static)
-
- extern void AddFunDim(char *name, long lim,funptr callback);
- /* Setup routine to allow the XFun to return values based on the array index.
- This routine must be called by the predef routine. It can be called multiple times
- to set up a multidimensional return value. Array index values are appended to the
- parameter list */
-
- extern void ErrMsg(char *fmt,char *str,funptr callback);
- /* Show an error message in the status line.
- fmt is a printf() format string. str is an optional parameter
- Sets stop flag to tell MathPad to stop all evaluation. */
-
- extern short Stopped(funptr callback);
- /* Check value of stop flag to see if evaluation should be stopped. */
-
- extern void SpinWatch(funptr callback);
- /* Allow a computation to be switched to background or stopped via command period.
- Stopped() must be checked to see if command period was hit.
- SpinWatch() should be called at least twice per second.
- It can be called at a much higher rate without much loss. */
-
- extern void ReturnVoid(funptr callback);
- /* Allow the XFun to return false without generating an error message. */
-
-
- /* ------------- function parameter access ---------------- */
- /* Parameters are numbered from right to left starting at 0 */
-
- extern short GetParmVal(long n,double *num,funptr callback);
- /* Get the value of a simple numeric parameter.
- Returns false if the value is an array or undefined */
-
- extern void MakeParmExpr(long n,EXPR *xpr,funptr callback);
- /* Make a parameter expression. (Used to access arrays).
- The expression must be deallocated with FreeExpr(xpr). */
-
- extern short GetParmName(long n,char **name,funptr callback);
- /* Get a name parameter. (Used to get a filename or other string).
- Returns false if the parameter was an expression or defined variable */
-
-
-
- /* ------------------ global variable access ---------------- */
-
- extern short GetVarVal(char *name,double *num,funptr callback);
- /* Evaluate the named global variable.
- Returns false if the value is an array or undefined */
-
- extern void GetVarString(char *name,char **str,funptr callback);
- /* Returns the string value of a named global variable.
- Returns an empty string if unless the variable was set to a string */
-
- extern void MakeVarExpr(char *name,EXPR *xpr,funptr callback);
- /* Make a global variable expression. (Used to access arrays).
- The expression must be deallocated with FreeExpr(xpr). */
-
- extern short SetVarVal(char *name,double num,funptr callback);
- /* Assign a single value to the named global variable.
- Returns false if the variable is an illegal destination. */
-
- extern short SetVarMatrix(char *name,double *arr,long rows,long cols,funptr callback);
- /* Assign a 1D or 2D array to the named global variable.
- Returns false if the variable is an illegal destination.
- The array must be allocated via NewPtr() and will be deallocated by MathPad. */
-
- extern void FoldVar(char *name,long lim,funptr callback);
- /* Add a dimension to the variable set by SetVarMatrix(). Can be called multiple
- times to create more dimensions. */
-
-
-
- /* ------------ general expression routines ----------------- */
-
- extern short GetExprMatrix(EXPR xpr,double **mat,long *rows,long *cols,funptr callback);
- /* Allocate memory and evaluate all elements of a 1D or 2D matrix expression into memory.
- Returns a pointer to the matrix in mat.
- A scalar will return cols=0 and rows=0. A 1D array will return cols=0.
- An array with more than 2 dimensions will generate an error message and return false.
- The matrix allocated by GetExprMatrix() should be deallocated with DisposPtr() */
-
- extern short ProbeExpr(EXPR xpr,double *num,short *isarray,long *count,funptr callback);
- /* Find out if an expression is a scalar or an array.
- If scalar, returns true and sets num.
- If array, returns false and sets isarray and count. A count of 0 means infinite array.
- If the return value and isarray are both false the expression was undefined. */
-
- extern void AddIndex(EXPR *xpr,double **iptr,funptr callback);
- /* Add an index to allow evaluating individual array elements.
- The double at iptr can be modified to index through the array.
- To access a single element, an index must be added for each dimension of the array. */
-
- extern void RemoveIndex(EXPR *xpr,funptr callback);
- /* Can be used to remove the last index added by AddIndex(). Normally FreeExpr() is
- be used to free the entire expression so this call is not required. */
-
- extern short EvalExpr(EXPR xpr,double *num,funptr callback);
- /* Evaluate an expression. Returns false if xpr is an array or undefined.*/
-
- extern void FreeExpr(EXPR xpr,funptr callback);
- /* Free memory allocated to an expression.
- Use to deallocate from MakeParmExpr() or MakeVarExpr() */
-
-
- /* ---------- PICT overlay ---------------- */
-
- extern void SetPlotPICT(PicHandle thePic,funptr callback);
- /* Allows an XFun to overlay PICT graphics on the plot. Overlay goes on current strip.
- The XFun must allocate and create thePic. MathPad will dispose of it. */
-
- extern void SizePlotPICT(double left,double bot,double width,double ht,funptr callback);
- /* Specify where to draw the PICT in data coordinates.
- Default is to size the PICT to fill the data plot area. */
-
-
- /* ---------- Document info ----------- */
-
- short GetDocInfo(long *docref,FSSpec *fspec,WindowPtr *plotwindow,funptr callback);
- /* Get info about the document being evaluated. Returns false if no doc is open. */
-
- extern void GetAngleUnits(double *unit,funptr callback);
- /* Get the currently selected multiplier trig function parameters.
- 1.0 for radians, .017 for degrees */
-
- extern void GetAxisRect(Rect *axisrect,funptr callback);
- /* Get the current data axis rectangle in plot window coordinates */
-
- extern void GetAxisLimits(double limits[6],funptr callback);
- /* Get the the current values of xmin,xmax,ymin,ymax,zmin,zmax */
-
- extern void GetPlotInfo(double info[12],funptr callback);
- /* Get the the current values of xlo,xhi,ylo,yhi,zlo,zhi,
- traceclick,xclick,yclick,zclick,ixclick,iyclick */
-
-
- /* -------------- Utillity --------------------*/
- extern short Sprintf(char *buf,char *fmt,double num,funptr callback);
- /* Allows XFun some access to sprintf() without linking its own ANSI library */
-
- extern void MapData(double x,double y,short *xpixel,short *ypixel,funptr callback);
- /* use current plot window scaling to convert data coords to pixel coords */
-
-
- #ifdef __cplusplus
- }
- #endif
-